package com.ihome.excel.xlsx.engine.imports.test;

import java.util.List;
import java.util.Map;

import org.junit.Test;

import com.ihome.excel.xlsx.engine.imports.ExcelParserEngine;
import com.ihome.excel.xlsx.test.entity.Customer;
import com.ihome.excel.xlsx.test.entity.Student;
import com.ihome.excel.xlsx.test.validaterule.CustomerRowsValidate;
import com.ihome.excel.xlsx.test.validaterule.MapRowsValidate;
import com.ihome.excel.xlsx.test.validaterule.StudentImportValidateRule;
import com.ihome.excel.xlsx.validate.IRowsValidateRule;

public class ExcelParseEngineTesting {

    @Test
    public void test_Import(){
        ExcelParserEngine studentParser = new ExcelParserEngine();
        List<Student> studentList = studentParser.getResultAsFilePath("src/test/resources/student.xlsx");
        for(Student stu : studentList){
            System.out.println(stu.toString());
        }
    }
    
    @Test
    public void test_Customer_Import(){
        ExcelParserEngine studentParser = new ExcelParserEngine();
        List<Customer> customerList = studentParser.getResultAsFilePath("src/test/resources/customer.xlsx");        
    }
    
    @Test
    public void test_Customer_RowValidate_Import(){
        ExcelParserEngine studentParser = new ExcelParserEngine();
        IRowsValidateRule rowValidateRule = new CustomerRowsValidate();
        List<Customer> customerList = studentParser.getResultAsFilePath("src/test/resources/customer.xlsx",rowValidateRule);
    }
    
    @Test
    public void test_Validate_Import(){
        ExcelParserEngine studentParser = new ExcelParserEngine();
        List<Student> studentList = studentParser.getResultAsFilePath("src/test/resources/student.xlsx",new StudentImportValidateRule());
        for(Student stu : studentList){
            System.out.println(stu.toString());
        }
        
    }
    
    @Test
    public void test_mapImport(){
        ExcelParserEngine parser = new ExcelParserEngine();
        List<Map> mapList = parser.getResultAsFilePath("src/test/resources/mapstu.xlsx",new StudentImportValidateRule(),new MapRowsValidate());
        for(Map map : mapList){
            System.out.println(map.get("id"));
            System.out.println(map.get("name"));
            System.out.println(map.get("address"));
            System.out.println(map.get("amount"));
        }
    }
    
    
}
